package com.heima.leadnews.article.controller.v1;

import com.heima.leadnews.article.service.ArticleService;
import com.heima.model.article.dtos.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
public class ArticleController {
    @Autowired
    ArticleService articleService;
    //**加载首页**
@PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto){
                  Short type=3;
    return articleService.loadArticle(dto,type);

}
//**加载更多**
    @PostMapping("/loadmore")
    public ResponseResult loadmore(@RequestBody ArticleHomeDto dto){
        Short type=1;
        ResponseResult result= articleService.loadArticle(dto,type);
        return  ResponseResult.okResult(result);
    }
   // **加载最新**
    @PostMapping("/loadnew")
    public ResponseResult loadnew(@RequestBody ArticleHomeDto dto){
        Short type=2;
        ResponseResult result= articleService.loadArticle(dto,type);
        return  ResponseResult.okResult(result);
    }
}
